package com.ruirenyun.util.common;

/**
 * Created by chenghao on 2017/10/24.
 */
public class PayUtil {

    /**
     * 获取订单号
     * @return
     */
    public synchronized static String getOutTradeNo(){
        return String.valueOf(System.currentTimeMillis()) + getRandomNum(4);
    }

    /**
     * 获取N位随机整数
     * @param n
     * @return
     */
    public static int getRandomNum(int n){
        String s1 = "9";
        String s2 = "1";
        for(int i = 0; i < n - 1; i++){
            s1 += "0";
            s2 += "0";
        }
        int code = (int) (Math.random() * Integer.parseInt(s1) + Integer.parseInt(s2));
        return code;
    }

}
